package cn.smbms.service.provider;

import cn.smbms.dao.provider.ProviderMapper;
import cn.smbms.pojo.Provide;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("providerService")
public class ProviderServiceImpl implements ProviderService{//

   @Resource
    private ProviderMapper providerMapper;

    @Override
    public int getProviderCount(String queryProCode, String queryProName){
        int count = 0;
        System.out.println("queryProCode ---- > " + queryProCode);
        System.out.println("queryProName ---- > " + queryProName);
        count = providerMapper.getProviderCount(queryProName,queryProName);
        return count;
    }

    public List<Provide> getProviderList(String queryProCode, String queryProName,
                                  int currentPageNo, int pageSize) {
        int beginIndex = (currentPageNo-1)*pageSize;
        return providerMapper.getProviderList(queryProCode, queryProName, beginIndex,
                pageSize);
    }

    @Override
    public boolean add(Provide provide) {
        return providerMapper.add(provide) > 0;
    }

    @Override
    public Provide getProvideById(String id) {
        return providerMapper.getProvideById(id);
    }

    @Override
    public boolean modify(Provide provide) {
        return providerMapper.modify(provide) > 0;
    }
}
